/*
 * $Id$
 *
 * Copyright (C) IUT Montreuil-University Paris 8, 2009-2010
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */

package fr.univ_paris8.iut.linc.align;

import java.util.ArrayList;



public class Graph {
	public ArrayList <Concept> ListConcept;
	public ArrayList <Property> ListProperty;
	public ArrayList <Edge> ListEdge;
	
	public Graph() {
		ListConcept = new ArrayList<Concept>();
		ListProperty = new ArrayList<Property>();
		ListEdge = new ArrayList<Edge>();
	}

	
	public void afficherGraph (Graph gh){
		
		System.out.println ("Les concepts : ");
		for (int i=0;i<gh.ListConcept.size();i++)
			System.out.println (gh.ListConcept.get(i).getName());
		
		System.out.println ("Les propri�t�s : ");
		
		
		
		for (int i=0;i<gh.ListProperty.size();i++)
			//if (gh.ListProperty.get(i)!=null)
			System.out.println (gh.ListProperty.get(i).getName()+ " " +gh.ListProperty.get(i).getRestriction()
					+ " "+ gh.ListProperty.get(i).getCardinality());
		
		System.out.println ("Les arcs : ");
		for (int i=0;i<gh.ListEdge.size();i++)
		{
			if (gh.ListEdge.get(i).getSimpleType()!="")
				System.out.println (gh.ListEdge.get(i).getSource().getName()+ ">>" + gh.ListEdge.get(i).getSimpleType()
					+ ">>" + gh.ListEdge.get(i).getTarget().getName());
			else
				System.out.println (gh.ListEdge.get(i).getSource().getName()+ ">>" 
						+ gh.ListEdge.get(i).getCompoundType().getRestriction()
						+ " " +gh.ListEdge.get(i).getCompoundType().getCardinality()+ ":" 
						+ gh.ListEdge.get(i).getCompoundType().getName()+">>" 
						+ gh.ListEdge.get(i).getTarget().getName());
		}
		
			
	}

public ArrayList <Concept> getSuperClasses	(Concept C, Graph gh){
	ArrayList <Concept> sup = new ArrayList<Concept>();
	for (int i = 0; i<gh.ListEdge.size();i++){
		if (gh.ListEdge.get(i).getSimpleType().equals("SubClass"))
			if ((gh.ListEdge.get(i).getSource().equals(C))&&(!(gh.ListEdge.get(i).getTarget().getName().equals("owl:Thing")))
				&&(!sup.contains(gh.ListEdge.get(i).getTarget())))
				sup.add(gh.ListEdge.get(i).getTarget());
	}
	return sup;
}

public void AfficherSuperClasses (ArrayList <Concept> sup){
	for (int i =0; i<sup.size();i++)
		System.out.println (sup.get(i));
}
}